/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ventanajuego;


import java.awt.event.KeyEvent;
import javax.swing.*; // For JPanel, etc.
import java.awt.*; // For Graphics, etc.
import java.awt.event.KeyListener;
import java.awt.geom.*; // For Ellipse2D, etc.

import ventanajuego.Juegador;

public class VentanaJuego extends JFrame implements KeyListener{

    private Juegador player;

    public VentanaJuego(){
        super ("Juego");
        Container c = getContentPane();
        c.setLayout(new FlowLayout());
        this.setSize(800,600);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setBackground(Color.GRAY);
        addKeyListener(this);
        
    }

    @Override
    public void paint(Graphics g){
        super.paint(g); //para que en el fondo haya gris viste XD


        Graphics2D g2 = (Graphics2D)g;

        
        g2.setColor(Color.MAGENTA);
        
        
        GradientPaint gp1 = new GradientPaint(50.0f,25.0f,Color.blue, 50.0f, 400.0f, Color.black);//hacemso el gradiente de fondo
        g2.setPaint(gp1);
        Rectangle2D r1 = new Rectangle2D.Float(10, 10, 790, 690);
        g2.fill(r1);

        Rectangle2D r2 = new Rectangle2D.Float(75, 50, 100, 25);
        g2.setColor(Color.black);
        Stroke pincel = new BasicStroke(4.0f, BasicStroke.CAP_SQUARE,BasicStroke.JOIN_ROUND);
        g2.setStroke(pincel);
        g2.draw(r2);

        

        Line2D line = new Line2D.Float(200.0f, 50.0f, 200.0f, 400.0f);
        g2.setStroke(new BasicStroke(3.0f));
        g2.setColor(Color.YELLOW);
        g2.draw(line);

        Juegador player1 = new Juegador(50,50, 100, 100);
        g2.setColor(Color.WHITE);
        g2.setStroke(pincel);
        g2.draw(player1);


        
    }

    public static void main(String[] ags){
        VentanaJuego ventana = new VentanaJuego();

       
    }

    public void keyTyped(KeyEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void keyPressed(KeyEvent e) {
       player.keyPressed(e);
    }

    public void keyReleased(KeyEvent e) {
        player.keyReleased(e);
    }




}
